#!/usr/bin/env bash

set -euo pipefail

# type check / generate dts files
tsc
rm dist/*.spec.d.ts*

# bundle
tsup

api-extractor run \
  --local \
  --verbose

api-documenter markdown \
  -i temp \
  -o docs/api

# disable edit links in generated docs
find docs/api \
  -type f \
  -name '*.md' \
  | xargs sed -i '1s|^|---\neditLink: false\n---\n|'

# remove old dts files after api-extractor generated the new one
find dist | grep -P '.*(?<!vue-metamorph)\.d\.ts.*' | xargs rm
